import org.apache.ibatis.session.SqlSession;
import org.example.Utils.MyBatisUtils;
import org.example.pojo.Employee;
import org.junit.Test;

public class EmployeeTest {
    @Test
    public void findEmployeeTest(){
        SqlSession session = MyBatisUtils.MyBatisUtils.getSession();
        Employee Employee = session.
                selectOne("org.example.mapper.EmployeeMapper.selectByPrimaryKey",(long)1);
        System.out.println(Employee);
        session.commit();
        session.close();
    }
    @Test
    public void insertEmployeeTest(){
        SqlSession session = MyBatisUtils.getSession();
        Employee employee = new Employee();
        employee.setId(7);
        employee.setName("王八");
        employee.setAge(Integer.valueOf("18"));
        employee.setPosition("员工");
        int rows = session.update("org.example.mapper.EmployeeMapper.updateByPrimaryKeySelective",employee);
        System.out.println(rows);
        session.commit();
        session.close();
    }
    @Test
    public void deleteEmployeeTest(){
        SqlSession session = MyBatisUtils.getSession();
        int rows = session.delete("org.example.mapper.EmployeeMapper.deleteByPrimaryKey",5L);
        System.out.println(rows);
        session.commit();
        session.close();
    }
}
